const mongoose = require('mongoose')
const Schema = mongoose.Schema
const adInfo = new Schema({
  nation: { type: String, required: true },
  province: { type: String, required: true },
  city: { type: String, required: true },
  district: { type: String},
  adcode: { type: String },
  nation_code: { type: String},
  lat: { type: String, required: true },
  lng: { type: String, required: true },
  lastTime: { type: String, required: true },
  totNum: { type: Number, required: true },
})
const visitorInfoCollection = new Schema({
  // 这张表拥有哪些字段
  adInfoOb: adInfo,
  ip: { type: String, required: true },
})
visitorInfoCollection.index({ 'adInfoOb.lastTime': -1 })
const VisitorInfo = mongoose.model('VisitorInfo', visitorInfoCollection)

module.exports = VisitorInfo
